package com.huawei.chapter01.project1;

import java.util.Scanner;
public class Days {
    public static void main(String[]args) {
        int year, month, days;               // 存放年、月、天数的变量
        System.out.println("请输入年、月");  // 输入提示
        Scanner in = new Scanner(System.in);
        year = in.nextInt();
        month = in.nextInt();
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:		days = 31; break; // break跳出整个switch语句
            case 4:
            case 6:
            case 9:
            case 11:		days = 30; break; // break跳出整个switch语句
            case 2:
                if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) //判断是否闰年
                    days = 29;
                else
                    days = 28;
                break;
            default:		days = 0; // 输入月份不对
        }
        System.out.println(year + "年" + month + "月有" + days + "天");
    }
}

